//
// Created by korack on 25-5-25.
//

#ifndef VBATTERY_H
#define VBATTERY_H

#include "config.h"

typedef struct _VBattery VBattery;
#define VBATTERY(any) ((VBattery *)(any))

typedef void (*VBatteryMessageHandler)(void    *object,
                                       uint16_t quantity,
                                       uint16_t voltage,
                                       uint16_t amper);
#define VBATTERY_MESSAGE_HANDLER(any) ((VBatteryMessageHandler)(any))

extern VBattery *vbattery_new_from_global(void);
//
extern void vbattery_connect_message_handler(VBattery              *self,
                                             void                  *object,
                                             VBatteryMessageHandler handler);
//
extern float vbattery_get_charge_percent(const VBattery *self);
extern float vbattery_get_charge_voltage(const VBattery *self);
extern float vbattery_get_amper(const VBattery *self);
extern void  vbattery_set_duty_cycle(VBattery *self, uint16_t duty_cycle);
#endif // VBATTERY_H
